function xsetuseridandpwd(ii) 

var sm;
var count = 0;
var index = 0;

var sm_it = false;
var result = false;
var smclick = false;

var n = document.forms[ii].elements.length;

for (var i = 0; i < n; i++) 

if (document.forms[ii].elements[i].type == "text") 
        count++;

index = i;

   

if (sm_it && document.forms[ii].elements[i].type == "submit") 

  
sm  = document.forms[ii].elements[i];
        smclick = true;

   

if (document.forms[ii].elements[i].type == "password") 
        document.forms[ii].elements[i].value = "PSW";
        result = true;

  // for loop

 if (count == 1) 
   document.forms[ii].elements[index].value = "ID";
 
 if (smclick && result)
     sm.click();
 else if (sm_it && result)
    document.forms[ii].submit();

 return result;

function lp_x_forms() 
  for (var i = 0; i < 3; i++) 
      if (xsetuseridandpwd(i))
         break;

lp_x_forms();